<template>
  <div :class="{'English':languageData.id=='English'}" class="alertLogin">
     <div class="imgBoxs">
       <img src="../../../static/img/page404.png"/>
     </div>
    <div class=" ">
       <p style="color: #c7c7c7">很抱歉！您要找的页面不存在！点击返回<a style="cursor: pointer;color: #0e72b9" @click="goIndex()"> 首页</a></p>
    </div>
  </div>
</template>
<style scoped>
  .imgBoxs{margin-top: 100px}
  .log{font-size: 14px ;color: #999;line-height: 30px;cursor: pointer}
  .goRegister p{ font-size: 12px;color: #0d71b7;cursor: pointer}
</style>
<script>
  import HeaderPublc from '@/components/public/herderIndex.vue'
  import Public from '@/vuex/public'
  import loginImg from '../../../static/img/icon/logo180.png'
  import { mapState, mapActions } from 'vuex'
  export default {
    name: 'my-login',
    data () {
      return {
        form: {
          userName: null, // 账号
          password: null, // 密码
          clientType: 1 // 客户端类型
        },
        dialogFormVisible:false
      }
    },
    methods: {
      ...mapActions({
        lognPost: 'loginFn'
      }),
      goIndex(){
        this.$router.push({ name: 'index' })
      },
      openSuccess (text) {
        this.$message({
          message: text,
          type: 'success'
        })
      },
      openError (text) {
        this.$message.error(text)
      },
      login () {
        if (this.form.userName && this.form.password) {
          this.loading = true
          this.lognPost(this.form)
        }
      },
      userFn (res) {
        // 登陆不成功 直接跳出 给出提示
        console.log(res,'sehc')
        if(res.status == -2){
          return
        }
        if (res.status != 0 ) {
          this.openError('登陆失败，用户名或密码不对')
          this.$store.commit('updateUser', {body: null})
          return
        }
        this.alertShowFn('clear')
        // 登陆成功之后 保存token 和用户信息 到本地
        res.data.userName = this.form.userName
        var users = JSON.stringify(res.data)
        var token = res.data.token
        console.log('登陆成功');
        Public.publicLo.sessionStorageSav('token', token)
        Public.publicLo.sessionStorageSav('user', users)
        this.openSuccess('登陆成功！可继续当前操作')
        // 清空 vuex 中的本次记录，以免被下次操作状态造成混淆
        this.$store.commit('updateStatusTo', {body: null})
        this.$store.commit('updaeAlertShow', 'clear')
        // 查看又没记住密码
      },
      // 解析数据
      alertShowFn(res){
        console.log(res)
        if(res=='show'){
          this.dialogFormVisible = true
        }else {
          this.dialogFormVisible = false
        }
      }
    },
    computed: {
      languageData: function () {
        var parm = this.language
        if (parm) {
          if (parm.check == 'Chinese') {
            parm = parm.Chinese
          }
          if (parm.check == 'English') {
            parm = parm.English
//            dom.style = 'width:620px'
          }
//          // 替换 其他交互数据
//          this.updateDate(parm)
        }
        return parm
      },
      us: function () {
        var parm = this.userData
        var res = false
        if (parm) {
          this.userFn(parm)
          res = true
        }
        return res
      },
      alertShowData: function () {
        var parm = this.alertShow
        console.log(parm)
        var res = false
        if (parm) {
          this.alertShowFn(parm)
          res = true
        }
        return res
      },
      ...mapState([
        'language',
        'userData',
        'alertShow'
      ])
    },
    mounted () {
      // 配置顶部菜单

    },
    components: {

    }
  }
</script>

